package com.cyjt.operation.adapter;

import java.util.List;

import com.cyjt.operation.R;
import com.cyjt.operation.bean.MessageManagement;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * 消息管理的ListView的自定义适配器
 * 
 * @author LTP
 *
 */
public class MessageManagementAdapter extends ArrayAdapter<MessageManagement> {
	private int listViewResourceId;

	public MessageManagementAdapter(Context context, int resource, List<MessageManagement> objects) {
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
		listViewResourceId = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		MessageManagement messageManagement = getItem(position);
		View view;
		ViewHolder mViewHolder;
		if (convertView == null) {
			view = LayoutInflater.from(getContext()).inflate(listViewResourceId, null);
			mViewHolder = new ViewHolder();
			mViewHolder.messageText = (TextView) view.findViewById(R.id.textView_message_management);
			view.setTag(mViewHolder);
		} else {
			view = convertView;
			mViewHolder = (ViewHolder) view.getTag();
		}
		mViewHolder.messageText.setText(messageManagement.getWorkOrderMessage() + "");
		return view;
	}

	class ViewHolder {
		TextView messageText;
	}
}
